from rest_framework.pagination import *


class CustomPageNumberPagination(PageNumberPagination):

    page_size = 10
    page_size_query_param = 'page_size'

    def get_paginated_response(self, data):
        return Response({
            'total': self.page.paginator.count,
            **data
        })

    def get_paginated_response_schema(self, schema):
        return {
            'type': 'object',
            'properties': {
                'total': {
                    'type': 'integer',
                    'example': 123,
                },
                'msg': {
                    'type': 'string',
                    'nullable': True,
                    'example': '一些信息',
                },
                'results': schema,
            },
        }
